﻿<phone:PhoneApplicationPage xmlns:toolkit="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Toolkit"  
    x:Class="QWeiBoN.UserControler.CommentsList"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
    xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:uc="clr-namespace:QWeiBoN.UserControler"
    xmlns:converter="clr-namespace:QWeiBoN.Converter"
    xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
    FontFamily="{StaticResource PhoneFontFamilyNormal}"
    FontSize="{StaticResource PhoneFontSizeNormal}"
    Foreground="{StaticResource PhoneForegroundBrush}"
    SupportedOrientations="Portrait" Orientation="Portrait"
    mc:Ignorable="d" d:DesignHeight="768" d:DesignWidth="480"
    shell:SystemTray.IsVisible="True">

    <phone:PhoneApplicationPage.Resources>
        <converter:ConvertWeiboContentBehavior x:Key="ConvertWeiboContentBehavior" />
    </phone:PhoneApplicationPage.Resources>

    <!--LayoutRoot 是包含所有页面内容的根网格-->
    <Grid x:Name="LayoutRoot" Background="Transparent">
        <Grid.RowDefinitions>
            <RowDefinition Height="5"/>
            <RowDefinition Height="100"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>
        
        <!-- 进度条 -->
        <toolkit:PerformanceProgressBar Width="400" Grid.Row="0" VerticalAlignment="Bottom" HorizontalAlignment="Center" x:Name="CommentProgressBar" IsIndeterminate="False" />
        
        <!-- 输入框 -->
        <StackPanel Grid.Row="1" Orientation="Vertical">
            <TextBox x:Name="CommentTextBox" Style="{StaticResource CommentTextBoxContentStyle}" VerticalScrollBarVisibility="Auto"></TextBox>
        </StackPanel>
        
        <!-- 在这里放置评论列表 -->
        <Grid x:Name="ContentPanel" Grid.Row="2" Margin="12,0,12,0">
            <ListBox x:Name="CommentsListView" ItemsSource="{Binding Singleline}" VerticalAlignment="Top" HorizontalAlignment="Left">
                <ListBox.ItemTemplate>
                    <DataTemplate>
                        <Grid Margin="0,10,0,0" VerticalAlignment="Top">
                            <Grid.RowDefinitions>
                                <RowDefinition Height="Auto" />
                                <RowDefinition Height="Auto" />
                            </Grid.RowDefinitions>
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="60" />
                                <ColumnDefinition Width="*" />
                            </Grid.ColumnDefinitions>
                            <StackPanel HorizontalAlignment="Left" VerticalAlignment="Top">
                                <Image Name="UserHeader" Margin="0,5,0,0"  Stretch="None" Source="{Binding Head}"  HorizontalAlignment="Left" VerticalAlignment="Top" Tag="{Binding Name}" />
                            </StackPanel>
                            <StackPanel Grid.Column="1" Grid.Row="0" HorizontalAlignment="Left">
                                <StackPanel Orientation="Horizontal" HorizontalAlignment="Left" Margin="0,0,0,0" VerticalAlignment="Top">
                                    <TextBlock TextWrapping="Wrap" Text="{Binding Nick}" Width="340" HorizontalAlignment="Left" VerticalAlignment="Top" Padding="0" />
                                    <HyperlinkButton Name="rePostLink" Content="收听" FontSize="18" Tag="{Binding OpenId}" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="0,0,0,0" />
                                </StackPanel>
                                <!--
                                <TextBlock TextWrapping="Wrap" Text="{Binding Origtext}" HorizontalAlignment="Left" VerticalAlignment="Top" Padding="0" Margin="0,5,0,0"/>
                                -->
                                <RichTextBox Padding="0" FontSize="21" Margin="-10,5,0,0" TextWrapping="Wrap" HorizontalAlignment="Left" VerticalAlignment="Top" Tag="{Binding Id}" CacheMode="BitmapCache">
                                    <i:Interaction.Behaviors>
                                        <converter:ConvertWeiboContentBehavior Content="{Binding Origtext}"></converter:ConvertWeiboContentBehavior>
                                    </i:Interaction.Behaviors>
                                </RichTextBox>
                            </StackPanel>
                            <StackPanel Grid.Row="1" Grid.Column="1" HorizontalAlignment="Left" Margin="0,10,10,10">
                                <TextBlock TextWrapping="Wrap" FontSize="15"  VerticalAlignment="Top" Width="340" Text="{Binding From}"/>
                            </StackPanel>
                        </Grid>
                    </DataTemplate>
                </ListBox.ItemTemplate>
                <!-- 手势 -->
                <toolkit:GestureService.GestureListener>
                    <toolkit:GestureListener GestureCompleted="GestureListener_GestureCompleted" DragStarted="GestureListener_DragStarted"/>
                </toolkit:GestureService.GestureListener>
            </ListBox>
        </Grid>
        <!-- 表情 -->
        <uc:FaceList x:Name="FaceSelect"/>
        <!-- 用于关闭软键盘 -->
        <Button x:Name="CBtn" Margin="0,-10,0,0" Width="1" Height="1" BorderThickness="0"/>
    </Grid>
 
    <!--ApplicationBar代码-->
    <phone:PhoneApplicationPage.ApplicationBar>
        <shell:ApplicationBar IsVisible="True" IsMenuEnabled="True" Opacity="0.6">
            <shell:ApplicationBarIconButton x:Name="CommentBarButton" Click="CommentBarButton_Click" IconUri="/Resources/icon/sent.png" Text="评论"/>
            <shell:ApplicationBarIconButton x:Name="FaceBarButton" Click="FaceBarButton_Click" IconUri="/Resources/icon/face.png" Text="表情"/>
            <shell:ApplicationBar.MenuItems>
                <shell:ApplicationBarMenuItem x:Name="ClearBarButton" Text="清除文字" Click="ClearBarButton_Click"/>
            </shell:ApplicationBar.MenuItems>
        </shell:ApplicationBar>
    </phone:PhoneApplicationPage.ApplicationBar>

</phone:PhoneApplicationPage>
